<?php

class Application_Form_Ticket extends Zend_Form
{
	protected $_tasks;
	
    public function init()
    {
    	$this->_tasks = new Application_Model_Tasks();
    	
        $this->setName('task');
        $this->setMethod('post');
        
        $date_ticket = new Zend_Form_Element_Text('date_ticket');
        $date_ticket->setLabel('Дата')
             ->setRequired(true)
             ->addFilter('StripTags')
             ->addFilter('StringTrim')
             ->addValidator('NotEmpty');
             
             
       $time_start = new Zend_Form_Element_Text('time_start');
       $time_start->setLabel('Начало час')
             ->setRequired(true)
             ->addFilter('StripTags')
             ->addFilter('StringTrim')
             ->addValidator('NotEmpty');
             
       $time_end = new Zend_Form_Element_Text('time_end');
       $time_end->setLabel('Край час')
             ->setRequired(true)
             ->addFilter('StripTags')
             ->addFilter('StringTrim')
             ->addValidator('NotEmpty');
             
       $task_id = new Zend_Form_Element_Select('task_id');
       $task_id->setLabel('Задача')
                   ->addFilter('Int')
                   ->setMultiOptions($this->_tasks->getTaskListSimple());
          
             
       $description = new Zend_Form_Element_Textarea('description');
       $description->setLabel('Описание')
             ->addFilter('StripTags')
             ->addFilter('StringTrim')
             ->setAttribs(array('cols' => 60, 'rows' => 4));
             
       $submit = new Zend_Form_Element_Submit('submit');
       $submit->setLabel('Запис');

        $this->addElements(array(
            $task_id, $date_ticket, $time_start, $time_end, $description, $submit
        ));

        $this->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'table', 'class' => 'form')),
            'Form'
        ));

        $this->setElementDecorators(array(
            'ViewHelper',
            'Errors',
            array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'value')),
            array('Label', array('tag' => 'td')),
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
        ));

        $submit->setDecorators(array(
            'ViewHelper',
            array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'value')),
            array(array('label' => 'HtmlTag'), array('tag' => 'td', 'class' => 'value', 'placement' => 'prepend')),
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
        ));
        
    }
    
}